package com.right.health.app.ui.registered.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.magic.basic.adapter.BaseAbsAdapter;
import com.right.health.app.R;
import com.right.health.app.bean.DoctorDetailResponse;

/*
 * Created by hopeliao on 2019-09-24
 *
 */
public class DoctorDetailTimeAdapter extends BaseAbsAdapter<DoctorDetailResponse.TimeBean> {


    public DoctorDetailTimeAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.doctor_detail_follow_time_item, null);
            viewHolder = new ViewHolder();
            viewHolder.weekTv = (TextView) convertView.findViewById(R.id.tv_week);
            viewHolder.timeTv = (TextView) convertView.findViewById(R.id.tv_time);
            viewHolder.lineView = convertView.findViewById(R.id.line_view);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.weekTv.setText(mDataSource.get(position).getWeek());
        viewHolder.timeTv.setText(mDataSource.get(position).getTime());
        viewHolder.lineView.setVisibility(position == mDataSource.size() - 1 ? View.INVISIBLE : View.VISIBLE);
        return convertView;
    }

    private class ViewHolder {
        private TextView weekTv, timeTv;
        private View lineView;
    }
}
